package com.xhwl.logistics.controller;

import com.xhwl.common.pojo.ResultJson;
import com.xhwl.logistics.bo.VehiclePayRecordStatisticsBO;
import com.xhwl.logistics.bo.VehicleAccessRecordStatisticsBO;
import com.xhwl.logistics.bo.input.QueryVehiclePayRecordStatisticsBO;
import com.xhwl.logistics.converter.ToQueryVehicleAccessRecordStatisticsBO;
import com.xhwl.logistics.converter.ToQueryVehiclePayRecordStatisticsBO;
import com.xhwl.logistics.converter.ToVehiclePayRecordStatisticsVO;
import com.xhwl.logistics.converter.ToVehicleAccessRecordStatisticsVO;
import com.xhwl.logistics.dto.query.VehiclePayRecordStatisticsDTO;
import com.xhwl.logistics.dto.query.VehicleAccessRecordStatisticsDTO;
import com.xhwl.logistics.service.IVehicleStatisticsService;
import com.xhwl.logistics.vo.VehiclePayRecordStatisticsVO;
import com.xhwl.logistics.vo.VehicleAccessRecordStatisticsVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Slf4j
//@RestController
public class VehicleStatisticsController {

    @Autowired
    private IVehicleStatisticsService vehicleStatisticsService;

    @Autowired
    private ToQueryVehicleAccessRecordStatisticsBO toQueryVehicleAccessRecordStatisticsBO;

    @Autowired
    private ToQueryVehiclePayRecordStatisticsBO toQueryVehiclePayRecordStatisticsBO;

    @Autowired
    private ToVehicleAccessRecordStatisticsVO toVehicleAccessRecordStatisticsVO;

    @Autowired
    private ToVehiclePayRecordStatisticsVO toVehiclePayRecordStatisticsVO;

    @PostMapping("/access-record/statistics")
    public ResultJson<VehicleAccessRecordStatisticsVO> accessRecordStatistics(@RequestBody VehicleAccessRecordStatisticsDTO vehicleAccessRecordStatisticsDTO) {

        VehicleAccessRecordStatisticsBO vehicleAccessRecordStatisticsBO = vehicleStatisticsService.accessRecordStatistics(toQueryVehicleAccessRecordStatisticsBO.toQueryVehicleAccessRecordStatisticsBO(vehicleAccessRecordStatisticsDTO));

        VehicleAccessRecordStatisticsVO vehicleAccessRecordStatisticsVO = toVehicleAccessRecordStatisticsVO.toVehicleStatisticsVO(vehicleAccessRecordStatisticsBO, vehicleAccessRecordStatisticsDTO.getType());

        return ResultJson.successWithResult(vehicleAccessRecordStatisticsVO);
    }

    @PostMapping("/pay-record/statistics")
    public ResultJson<VehiclePayRecordStatisticsVO> payRecordStatistics(@RequestBody VehiclePayRecordStatisticsDTO vehiclePayRecordStatisticsDTO) {

        QueryVehiclePayRecordStatisticsBO queryVehiclePayRecordStatisticsBO = toQueryVehiclePayRecordStatisticsBO.toQueryVehiclePayRecordStatisticsBO(vehiclePayRecordStatisticsDTO);

        VehiclePayRecordStatisticsBO vehiclePayRecordStatisticsBO = vehicleStatisticsService.payRecordStatistics(queryVehiclePayRecordStatisticsBO);

        VehiclePayRecordStatisticsVO vehiclePayRecordStatisticsVO = toVehiclePayRecordStatisticsVO.toVehiclePayRecordStatisticsVO(vehiclePayRecordStatisticsBO);
        return ResultJson.successWithResult(vehiclePayRecordStatisticsVO);
    }

}
